package globalvars

import "sync"

// 非导出结构体（隐藏实现细节）
type statusManager struct {
	networkStatus    bool
	loadConfigStatus bool
	mu               sync.RWMutex
}

// 包级变量直接初始化（线程安全）
var instance = &statusManager{networkStatus: false}

func GetNetworkStatus() bool {
	instance.mu.RLock()
	defer instance.mu.RUnlock()
	return instance.networkStatus
}

func SetNetworkStatus(online bool) {
	instance.mu.Lock()
	defer instance.mu.Unlock()
	instance.networkStatus = online
}

func GetLoadConfigStatus() bool {
	instance.mu.Lock()
	defer instance.mu.Unlock()
	return instance.loadConfigStatus
}

func SetLoadConfigStatus(loaded bool) {
	instance.mu.Lock()
	defer instance.mu.Unlock()
	instance.loadConfigStatus = loaded
}

//
//var serialNumber string
//var configPath string
//var configName string
//var localStorePath string
//
//var socketConfig *socketConfigArrayStruct
//var led485Config *led485ConfigArrayStruct
//var led485ConfigMap = make(map[string]*serial.Port)
//
////---------------------------------------------------------
//
//func init() {
//	//测试
//	socketConfig = newSocketConfigStruct()
//	led485Config = newLed485ConfigStruct()
//	serialNumber = "b06835cbdfd714a9"
//	localStorePath = "D:\\DevelopProject\\GolandSpace\\pictures\\"
//	configPath = "D:\\DevelopProject\\GolandSpace\\parking\\"
//	configName = "config.json"
//	////生产
//	//socketConfig = newSocketConfigStruct()
//	//led485Config = newLed485ConfigStruct()
//	//serialNumber = common.GetDeviceSerial()
//	//localStorePath = "/parking/pictures/"
//	//configPath = "/"
//	//configName = "config.json"
//}
//
//// ---------------------------------------------------------
//
//// socketConfigArrayStruct 设备socket连接配置结构体
//type socketConfigArrayStruct struct {
//	heartbeat   int
//	camerasInfo []*structs.CamerasInfoStruct
//}
//type led485ConfigArrayStruct struct {
//	led485Info []*structs.Led485ConfigStruct
//}
//type Led485ConfigInstance interface {
//	GetLed485Info() []*structs.Led485ConfigStruct
//	SetLed485Info(led485Info []*structs.Led485ConfigStruct)
//}
//
////---------------------------------------------------------
//
//func newSocketConfigStruct() *socketConfigArrayStruct {
//	return &socketConfigArrayStruct{
//		heartbeat:   60,
//		camerasInfo: nil,
//	}
//}
//func newLed485ConfigStruct() *led485ConfigArrayStruct {
//	return &led485ConfigArrayStruct{
//		led485Info: nil,
//	}
//}
//
////---------------------------------------------------------
//
//func GetSocketConfig() *socketConfigArrayStruct {
//	return socketConfig
//}
//
//func GetLed485Config() Led485ConfigInstance {
//	return led485Config
//}
//
//func GetLed485ConnMap() map[string]*serial.Port {
//	return led485ConfigMap
//}
//
//func GetDeviceSerial() string {
//	return serialNumber
//}
//
////func GetLed485Config() map[string]*serial.Port{
////	return led485Config
////}
//
////---------------------------------------------------------
//
//func (s *socketConfigArrayStruct) GetHeartbeat() int {
//	return s.heartbeat
//}
//
//func (s *socketConfigArrayStruct) SetHeartbeat(heartbeat int) {
//	s.heartbeat = heartbeat
//}
//
//func (s *socketConfigArrayStruct) GetCamerasInfo() []*structs.CamerasInfoStruct {
//	return s.camerasInfo
//}
//
//func (s *socketConfigArrayStruct) SetCamerasInfo(camerasInfo []*structs.CamerasInfoStruct) {
//	s.camerasInfo = camerasInfo
//}
//
//func (l *led485ConfigArrayStruct) GetLed485Info() []*structs.Led485ConfigStruct {
//	return l.led485Info
//}
//
//func (l *led485ConfigArrayStruct) SetLed485Info(led485Info []*structs.Led485ConfigStruct) {
//	l.led485Info = led485Info
//}
//
//func GetConfigPath() string {
//	return configPath
//}
//func GetConfigName() string {
//	return configName
//}
//
//func GetLocalStorePath() string {
//	return localStorePath
//}
